<template>
	<view class="hot-topic">
		<view class="hot-topic-title">
			<view>
				<view class="icon iconfont icon-icon-test"></view>
				热门话题
			</view>

			<view @tap="topicMore" class="icon iconfont icon-gengduo"></view>
		</view>
		<view class="hot-topic-info">
			<block v-for="(item, index) in hotTopicInfo" :key="index">
				<view class="topic-info" @tap="topipList(item)">
					<image :src="item.topicPic" mode="widthFix" lazy-load></image>
					<view :class="[hotTopicColors[index]]">#{{ item.topicName }}</view>
					<view>{{ item.topicNum }}个相关动态</view>
				</view>
			</block>
		</view>
	</view>
</template>

<script>
import imageCache from '../image-cache/image-cache.vue';
import { mapState, mapMutations } from 'vuex';
export default {
	components: {
		imageCache
	},
	props: {
		hotTopicInfo: Array
	},
	data() {
		return {
			hotTopicColors: ['hot-topic-color-blue', 'hot-topic-color-orange', 'hot-topic-color-pink']
		};
	},
	methods: {
		...mapMutations(['setSelectTopic']),
		topicMore() {
			uni.navigateTo({
				url: `../topic/topic?type=${1}`
			});
		},
		topipList(topic) {
			this.setSelectTopic(topic);
			uni.navigateTo({
				url: '../topic-type-list/topic-type-list'
			});
		}
	}
};
</script>

<style lang="less" scoped>
.hot-topic {
	padding: 0 20rpx;
	.hot-topic-title {
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		align-items: center;
		margin-bottom: 20rpx;
		& > view:first-child {
			display: flex;
			flex-direction: row;
			align-items: center;
			font-size: 32rpx;
			font-weight: 700;
			view {
				color: rgba(226, 81, 87, 0.75);
				font-weight: 400;
				margin-right: 10rpx;
			}
		}
		& > view:last-child {
			color: #999999;
		}
	}
	.hot-topic-info {
		display: flex;
		flex-direction: row;
		justify-content: space-around;
		align-items: center;

		.topic-info {
			position: relative;
			image {
				width: 220rpx;
				height: 220rpx;
				border-radius: 10rpx;
			}
			view {
				position: absolute;
				left: 10rpx;
				color: #ffffff;
				font-size: 22rpx;
			}
			& > view:nth-child(2) {
				line-height: 30rpx;
				border-radius: 20rpx;
				padding: 0 20rpx;
				bottom: 60rpx;
			}
			& > view:last-child {
				font-size: 22rpx;
				bottom: 20rpx;
			}
		}
	}
}
.hot-topic-color-blue {
	background: linear-gradient(to right, #e0d0ff, #beb1fc);
}
.hot-topic-color-orange {
	background: linear-gradient(to right, #ffcec9, #fdd9be);
}
.hot-topic-color-pink {
	background: linear-gradient(to right, #f0caf9, #fcc9d8);
}
</style>
